This is my first python programm. Just started here.
print("Hello World")
Hello World
$a=b+c$
x=3
%whos
Variable Type Data/Info ---------------------------- x int 3
print(type(x))
<class 'int'>
abcd=55.6
%whos
Variable Type Data/Info ----------------------------- abcd float 55.6 x int 3
a,b,c,d=1,3.4,"helow",-4
%whos
Variable Type Data/Info ----------------------------- a int 1 abcd float 55.6 b float 3.4 c str helow d int -4 x int 3
del abcd
print(abcd)
--------------------------------------------------------------------------- NameError Traceback (most recent call last) ~\AppData\Local\Temp/ipykernel_5724/224357748.py in <module> ----> 1 print(abcd) NameError: name 'abcd' is not defined
c=2+4j
type(c)
complex
%whos
Variable Type Data/Info ------------------------------- a int 1 b float 3.4 c complex (2+4j) d int -4 x int 3
sumOfaAndb=a+b
print(sumOfaAndb)
4.4
print(type(sumOfaAndb))
<class 'float'>
3**2
9
3*2
6
8/2
4.0
8//2
4
-
File "C:\Users\sayadur\AppData\Local\Temp/ipykernel_5724/476313318.py", line 1 - ^ SyntaxError: invalid syntax
_
4
print(2<3)
True
c=2<3
print(type(c))
print(c)
<class 'bool'> True
print((not(2!=3) and True) or (False and True))
False
print((not(2!=3) and True) or (False and True))
False
print((not(2!=3) and False) or (False and True))
False
round(467.67)
468
G=divmod(34,9)
type(G)
tuple
print(G)
(3, 7)
G[0]
3
G[1]
7
34/9
3.7777777777777777
34//9
3
34%9
7
print(isinstance(1,int))
True
l=isinstance(1,int)
print(type(l))
<class 'bool'>
isinstance(1.1,int)
False
isinstance(1.1,(float,int))
True
pow(2,4)
16
2**4
16
pow(2,4,7)
2
pow(2,4,8)
0
pow(3,4)
81
pow(3,4,8)
1
a=input("Enter a number:")
Enter a number:56
type(a)
str
a=int(a)
type(a)
int
x=int(input("Enter a number:"))
Enter a number:45
type(x)
int
pow?
help(input)
Help on method raw_input in module ipykernel.kernelbase:
raw_input(prompt='') method of ipykernel.ipkernel.IPythonKernel instance
Forward raw_input to frontends
Raises
------
StdinNotImplementedError if active frontend doesn't support stdin.
a=int(input())
b=int(input())
if a>b :
print("a is greater than b")
3 2 a is greater than b
a=int(input())
b=int(input())
if a>b :
print(a)
else:
print(b)
4 5 5
a=int(input())
b=int(input())
if a>b :
print(a)
else:
print(b)
File "C:\Users\sayadur\AppData\Local\Temp/ipykernel_8848/4258849755.py", line 5 else: ^ SyntaxError: invalid syntax
a=int(input())
b=int(input())
if a>b :
print("a is greate than b")
elif a==b:
print("a equal to b")
else:
print("b is greate than a")
29 29 a equal to b
a=int(input())
b=int(input())
if a>b :
print("a is greate than b")
elif a==b:
print("a equal to b")
else:
print("b is greate than a")
34 56 b is greate than a
a=int(input("Enter Number"))
if a>10 :
print("Your Number is above 10")
if a>20:
print("and also above 20")
else:
print("but not above 20")
else:
print("Your Number is below 10")
Enter Number1 Your Number is below 10
# Single line comments
"""
Muliti line Comments
Multilines Comments
"""
'\nMuliti line Comments\nMultilines Comments\n'
# Single line comments
"""
user will enter a floating input number let say 238.915. your
task is to find out the interger portion before the point (in this case)
and then check if that integer portion is even or odd number ?
"""
x=float(input("Enter a real number:"))
y=round(x)
if x>0:
if y>x:
intPortion=y-1
else:
intPortion=y
#print(intPortion)
else:
if y<x:
intPortion=y+1
else:
intPortion=y
if intPortion%2==0:
print("Even")
else:
print("Odd")
Enter a real number:98.98 Even
#Control flow (loops)
n=int(input("Maximum Iteration number:"))
i=1
while i<n:
if i%2==0:
print(i)
else:
pass
i += 1
print("Done")
Maximum Iteration number:10 2 4 6 8 Done
#Control flow (loops: break and continue)
n=int(input("Maximum Iteration number:"))
i=1
while True:
if i%9==0:
print("Break")
break
else:
i += 1
print("Continue")
continue
print("I am inside the loop")
print("Done")
Maximum Iteration number:10 Continue Continue Continue Continue Continue Continue Continue Continue Break Done
L=[]
type(L)
list
L=[]
for i in range(10):
print(i+1)
L.append(i**2)
1 2 3 4 5 6 7 8 9 10
L
[0, 1, 4, 9, 16, 25, 36, 49, 64, 81]
print(L)
[0, 1, 4, 9, 16, 25, 36, 49, 64, 81]
L=[]
for i in range(10):
print(i+1)
L.append(i**2)
print(L)
1 2 3 4 5 6 7 8 9 10 [0, 1, 4, 9, 16, 25, 36, 49, 64, 81]
S={"apple",4.9,"cherry"}
type(S)
set
S={"apple",4.9,"cherry"}
i=0
for x in S:
print(x)
i=i+1
if i==3:
break
else:
pass
else:
print("Loop is completed")
4.9 cherry apple
#Control flow (Exploring a dictionary)
D={"A":10,"B":-19,"C":"abc"}
for x in D:
print(x,D[x])
A 10 B -19 C abc
"""Given a list of number i.e. [1,2,3,4,-5,7,6,7,8]
that contains all the iterms in stored order from min to max. your
resutl will be another list [-5,1,2,3,4,5,6,7,8]
"""
L=[1,2,4,-5,7,6,9,3,2]
for j in range(len(L)):
m=L[j]
idx=j
c=j
for i in range(j,len(L)):
if L[i]<m:
m=L[i]
idx=c
c+=1
tmp=L[j]
L[j]=m
L[idx]=tmp
print(L)
[-5, 1, 2, 2, 3, 4, 6, 7, 9]
def printSuccess():
print("I am done")
print("Send me another task")
printSuccess()
I am done Send me another task
printSuccess()
I am done Send me another task
def printSuccess2():
"""this function does nothing"""
print("Send me another task")
len??
help(printSuccess)
Help on function printSuccess in module __main__: printSuccess()
help(printSuccess2)
Help on function printSuccess2 in module __main__:
printSuccess2()
this function does nothing
def printSuccess3(msg):
"""Function with argument"""
if isinstance(msg,str):
print(msg)
else:
print("Your argument is not a sting")
print("Here is the type what you have supplied ",msg)
printSuccess3("Test")
Test
printSuccess3(123)
Your argument is not a sting Here is the type what you have supplied 123
printSuccess3?
y="helow world"
printSuccess3(y)
helow world
def mypow(a,b):
""" This function compute poer just like builtin pow"""
c=a**b
print(c)
mypow(2,3)
8
def myAdd(a,b):
c =a+b
return c
myAdd(2,32)
34
d=myAdd(2,32)
print(d)
34
variableOUtsideFunstion=3
def g():
print(variableOUtsideFunstion)
g()
3
myAdd(c)
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) ~\AppData\Local\Temp/ipykernel_14092/2497071577.py in <module> ----> 1 myAdd(c) TypeError: myAdd() missing 1 required positional argument: 'b'
def r():
a=5
b=4
c=a+b
d="something"
return a,b,c,d
x,y,z,n=r()
print(x,y,z,n)
5 4 9 something
print(d)
34
print(n)
something
def myAddUniversal(*arg):
s=0
for i in range(len(arg)):
s+=arg[i]
return s
myAddUniversal(2,3,4,5,6)
20
def printAllVariableNameAndValues(**args):
for x in args:
print("variable Nameis:",x,"And Values is:",args[x])
printAllVariableNameAndValues(a=3,b="B",c="CCCC",y=10.7)
variable Nameis: a And Values is: 3 variable Nameis: b And Values is: B variable Nameis: c And Values is: CCCC variable Nameis: y And Values is: 10.7
import sys
sys.path.append('D:/sayadur/Data Science/mypythonmodules/')
import my_universal_functions as myfs
myfs.myAddUniversal??
c=myfs.myAddUniversal(2,4,5,7,-7,20)
print(c)
31
import sys
sys.path.append('D:/sayadur/Data Science/mypythonmodules/')
import my_universal_functions as myfs
c=myfs.myAddUniversal(2,4,5,7,-7,20)
print(c)
31
import sys
sys.path.append('D:/sayadur/Data Science/mypythonmodules/')
import my_universal_functions as myfs
c=myfs.myAddUniversal(2,4,5,7,-7,20)
vMyvalue=1234
d=myfs.checIfNotNumeric(vMyvalue)
print(c)
print(d)
print(myfs.myName)
31 True Python Course
"""Given a list of number i.e. [1,2,3,4,-5,7,6,7,8]
that contains all the iterms in stored order from min to max. your
resutl will be another list [-5,1,2,3,4,5,6,7,8]
"""
def findAscendingNo(L):
sys.path.append('D:/sayadur/Data Science/mypythonmodules/')
import my_universal_functions as myfs
v=0
for p in range(0,len(L)):
if myfs.checIfNotNumeric(L[p])==True:
x=L[p]
v+=1
z=x
else:
pass
return z
"""for j in range(len(z)):
m=z[j]
idx=j
c=j
for i in range(j,len(z)):
if z[i]<m:
m=z[i]
idx=c
c+=1
tmp=z[j]
z[j]=m
z[idx]=tmp"""
#return(z)
print(findAscendingNo([2,3,4,1,-6,8]))
8
print(findAscendingNo([2,3,4,1,-6,8,"hhhh"]))
--------------------------------------------------------------------------- NameError Traceback (most recent call last) ~\AppData\Local\Temp/ipykernel_14092/1088141836.py in <module> ----> 1 print(findAscendingNo([2,3,4,1,-6,8,"hhhh"])) ~\AppData\Local\Temp/ipykernel_14092/994433222.py in findAscendingNo(L) 12 x=L[p] 13 v+=1 ---> 14 return X 15 #Z[v]=x 16 else: NameError: name 'X' is not defined
import sys
sys.path.append('D:/sayadur/Data Science/mypythonmodules/')
import my_universal_functions as myfs
checIfNotNumeric?
Object `checIfNotNumeric` not found.
myfs.checIfNotNumeric??
def checIfNotNumeric(L):
for x in L:
if not(isinstance(x,(int,float))):
return False
return True
print(checIfNotNumeric([1,2,3]))
True
def checIfNotNumeric(L):
for x in L:
if not(isinstance(x,(int,float))):
return False
return True
def myAddUniversal(*args):
s=0
for i in range(len(args)):
s+=args[i]
return s
myName="Python Course"
"""Given a list of number i.e. ["a",2,3,4,1,-6,7,"hsdjfh"]
that contains all the iterms in stored order from min to max. your
resutl will be another list [-6, 1, 2, 3, 4, 7]
"""
def findAscendingNo(L):
sys.path.append('D:/sayadur/Data Science/mypythonmodules/')
import my_universal_functions as myfs
v=0
z=[]
for p in range(len(L)):
if myfs.checIfNotNumeric(L[p])==True:
z.append(L[p])
else:
pass
for j in range(len(z)):
m=z[j]
idx=j
c=j
for i in range(j,len(z)):
if z[i]<m:
m=z[i]
idx=c
c+=1
tmp=z[j]
z[j]=m
z[idx]=tmp
return(z)
print(findAscendingNo(["a",2,3,4,"kjsgdkjdf",1,-6,7,"hsdjfh"]))
--------------------------------------------------------------------------- NameError Traceback (most recent call last) ~\AppData\Local\Temp/ipykernel_1532/3154888157.py in <module> ----> 1 print(findAscendingNo(["a",2,3,4,"kjsgdkjdf",1,-6,7,"hsdjfh"])) ~\AppData\Local\Temp/ipykernel_1532/3023806591.py in findAscendingNo(L) 4 """ 5 def findAscendingNo(L): ----> 6 sys.path.append('D:/sayadur/Data Science/mypythonmodules/') 7 import my_universal_functions as myfs 8 v=0 NameError: name 'sys' is not defined
list1 = ['b','o','o','m']
list2 = ['r','e','d']
n = 2
new_list = []
for i in range(n): # append list1 until insert point
new_list.append(list1[i])
for i in list2: # append all of list2
new_list.append(i)
for i in range(n, len(list1)): # append the remainder of list1
new_list.append(list1[i])
print(new_list)
['b', 'o', 'r', 'e', 'd', 'o', 'm']
s="python is good language"
t='It good for data science'
print(s)
python is good language
print(t)
It good for data science
print(s+t)
python is good languageIt good for data science
a="""python is good language.
It good for data science """
print(a)
python is good language asjdgkajsd
print(a+s)
python is good language.
It good for data science python is good language
s="pyt5on is good language"
print(s[3:8])
print(len(s))
print(s[3])
type(s[3])
5on i 23 5
str
#Example of slicing
s="pyt5on is good language"
print(s[-8:-3])
print(s[-3:-1])
langu ag
s="""pyt5on is good language
Sayadur Rahaman"""
print(len(s))
print(s[-8:-3])
print(s[-3:-1])
47 Raha ma
s[0:12:2]
'pto sg'
a=" A Lot of Space at the beGinning and end "
a
' A Lot of Space at the beGinning and end '
b=a.strip()
b
'A Lot of Space at the beGinning and end'
print(b.lower())
a lot of space at the beginning and end
print(b.upper())
A LOT OF SPACE AT THE BEGINNING AND END
print(a.replace(" ",""))
ALotofSpaceatthebeGinningandend
print(a.replace(" ",""))
ALotofSpaceatthebeGinningandend
a="abc;def;hgyuiio;123"
L=a.split(";")
print(L)
['abc', 'def', 'hgyuiio', '123']
L[0]
'abc'
a.capitalize()
'Abc;def;hgyuiio;123'
c="hsgdj jhasgjdhas jhasgjdh"
print(c.capitalize())
Hsgdj jhasgjdhas jhasgjdh
c="hsgdj jhasgjdhas jhasgjdh"
c.capitalize()
'Hsgdj jhasgjdhas jhasgjdh'
print("at" in "asdfaatdea")
True
"bxc"<"aef"
False
print("we are learning \"string\" here")
we are learning "string" here
print('we are learning "string" here')
we are learning "string" here
print('we are \t learning here')
we are learning here
print('we are \n learning here')
we are learning here
print("c:\name\drive")
c: ame\drive
print(r"c:\name\drive")
c:\name\drive
"Data Structure"
L = [1,2,3,4.9,"name",3] #list
T = (1,2,3,4.9,"name",3) #Tuple
S = {1,2,3,4.9,"name",3} #Set
D = {23:"twothree",'B':43,'C':'CCD'} #Dictionary
print("The Type of L is",type(L))
print("The Type of T is",type(T))
print("The Type of S is",type(S))
print("The Type of D is",type(D))
The Type of L is <class 'list'> The Type of T is <class 'tuple'> The Type of S is <class 'set'> The Type of D is <class 'dict'>
print(D)
{23: 'twothree', 'B': 43, 'C': 'CCD'}
print(D[23])
twothree
print(L[1])
2
print(L[1])
print(T[1])
print(3 in S)
print(D[23])
2 2 True twothree
print(D['C'])
CCD
S
{1, 2, 3, 4.9, 'name'}
L
[1, 2, 3, 4.9, 'name', 3]
D
{23: 'twothree', 'B': 43, 'C': 'CCD'}
S
{1, 2, 3, 4.9, 'name'}
L[1:3]
[2, 3]
L[::-1]
[3, 'name', 4.9, 3, 2, 1]
L
[1, 2, 3, 4.9, 'name', 3]
T[:3]
(1, 2, 3)
L=L+["Game"]
L
[1, 2, 3, 4.9, 'name', 3, 'Game']
S.add("Game")
S
{1, 2, 3, 4.9, 'Game', 'name'}
S.remove("Game")
S
{1, 2, 3, 4.9, 'name'}
L.append(6.7)
L
[1, 2, 3, 4.9, 'name', 3, 'Game', 6.7]
T2 =('a','b')
T+T2
(1, 2, 3, 4.9, 'name', 3, 'a', 'b')
D['newkey']="Sayadur"
D
{23: 'twothree', 'B': 43, 'C': 'CCD', 'newkey': 'Sayadur'}
D2= {"y":"YYY",'z':"ZZZZ"}
D+D2
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) ~\AppData\Local\Temp/ipykernel_18504/3903222224.py in <module> ----> 1 D+D2 TypeError: unsupported operand type(s) for +: 'dict' and 'dict'
D.update(D2)
D
{23: 'twothree',
'B': 43,
'C': 'CCD',
'newkey': 'Sayadur',
'y': 'YYY',
'z': 'ZZZZ'}
L.pop?
L.pop
<function list.pop(index=-1, /)>
L.pop(1)
'name'
L
[1, 3]
T
(1, 2, 3, 4.9, 'name', 3)
D
{23: 'twothree', 'B': 43, 'C': 'CCD'}
S
{1, 2, 3, 4.9, 'name'}
L = [1,2,3,4.9,"name",3]
L
[1, 2, 3, 4.9, 'name', 3]
D2={'A':L,'B':T,'C':S,'D':D} #Here L=List,T=Tuple,S=Set,D=Dictinary
D2['A']
[1, 2, 3, 4.9, 'name', 3]
D2['D']
{23: 'twothree', 'B': 43, 'C': 'CCD'}
D2['A'][3]
4.9
K = D2['D']
K
{23: 'twothree', 'B': 43, 'C': 'CCD'}
for x in K:
print(x,K[x])
23 twothree B 43 C CCD
for x in K:
print(K[x])
twothree 43 CCD
L3=[L,T,S,D,"New data"]
L3
[[1, 2, 3, 4.9, 'name', 3],
(1, 2, 3, 4.9, 'name', 3),
{1, 2, 3, 4.9, 'name'},
{23: 'twothree', 'B': 43, 'C': 'CCD'},
'New data']
type(L3[-1])
str
type(L3[0])
list
type(L3[1])
tuple
type(L3[2])
set
type(L3[3])
dict
L3=[x**2 for x in range(10)]
L3
[0, 1, 4, 9, 16, 25, 36, 49, 64, 81]
S3={x**2 for x in range(12)}
S3
{0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121}
t={x**2 for x in range(12)}
t
{0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121}
type(t)
set
"""Let say you are teacher and you have different
student record containing of a student id, and marks list in
each subject where different student have taken duffernt
number of subects. All these records are in hard copy. you want to enter all the
data in computer and to compute the average marks of each student and display
"""
def getDataFromUser():
D={}
while True:
studentID=input("Enter Student ID:")
marksList=input("Enter the marks by comma separated values:")
moreStudents=input('Enter "no" to quite insertion:')
if studentID in D:
print(studentID,"is already inserted")
else:
D[studentID]=marksList.split(",")
if moreStudents.lower()=="no":
return D
studentData=getDataFromUser()
Enter Student ID:1 Enter the marks by comma separated values:80,56,89,87,98 Enter "no" to quite insertion:jhd Enter Student ID:2 Enter the marks by comma separated values:87,67,99,98,56 Enter "no" to quite insertion:hgkhgk Enter Student ID:3 Enter the marks by comma separated values:65,76,99,99,90 Enter "no" to quite insertion:ty Enter Student ID:3 Enter the marks by comma separated values:78,47,78,56,54 Enter "no" to quite insertion:gg 3 is already inserted Enter Student ID:4 Enter the marks by comma separated values:65,90,56,34,98 Enter "no" to quite insertion:no
studentData
{'1': ['80', '56', '89', '87', '98'],
'2': ['87', '67', '99', '98', '56'],
'3': ['65', '76', '99', '99', '90'],
'4': ['65', '90', '56', '34', '98']}
def getAvgMarks(D):
avgMarks={}
for x in D:
L=D[x]
s=0
for marks in L:
s += int(marks)
avgMarks[x]=s/len(L)
return avgMarks
avgM=getAvgMarks(studentData)
for x in avgM:
print("Student :",x," got avg marks as:",avgM[x])
Student : 1 got avg marks as: 82.0 Student : 2 got avg marks as: 81.4 Student : 3 got avg marks as: 85.8 Student : 4 got avg marks as: 68.6
import numpy as np
a= np.array([1,2,3,5,7,8])
b= np.array(("Sayadur","Rahaman","Ashik"))
print(a)
print(b)
[1 2 3 5 7 8] ['Sayadur' 'Rahaman' 'Ashik']
type(b)
numpy.ndarray
# 2 dimenion Array
import numpy as np
a=np.array([[1,2,3,5,7,8],[21,22,33,55,77,88],[11,32,31,51,71,81]])
print(a.ndim)
2
# 3 dimenion Array
import numpy as np
b=np.array([[[1,2,3,5,7,8],[21,22,33,55,77,88]],[[100,200,300,500,700,800],[210,220,330,550,770,880]]])
print(b.ndim)
3
# 1 dimenion Array
import numpy as np
c= np.array([1,2,3,5,7,8])
print(c.ndim)
1
b[1,0,2]
300
b[0,0,2]
3
b[0,1,4]
77
b[1,1,5]
880
print(b.shape[0],b.shape[1],b.shape[2])
2 2 6
print(b.shape)
(2, 2, 6)
print(a.shape)
(3, 6)
print(c.shape)
(6,)
c.size
6
b.size
24
b.nbytes
96
print(b)
[[[ 1 2 3 5 7 8] [ 21 22 33 55 77 88]] [[100 200 300 500 700 800] [210 220 330 550 770 880]]]
A=np.arange(100)
A
array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67,
68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99])
A=np.arange(20,100)
A
array([20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70,
71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87,
88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99])
A=np.arange(20,100,3)
# for i in range(20,100,3) means start from 20 increment by 3 upto 100
A
array([20, 23, 26, 29, 32, 35, 38, 41, 44, 47, 50, 53, 56, 59, 62, 65, 68,
71, 74, 77, 80, 83, 86, 89, 92, 95, 98])
print(range(10))
range(0, 10)
print(list(range(10)))
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
A=np.random.permutation(np.arange(10))
A
array([3, 8, 5, 9, 1, 6, 0, 2, 4, 7])
np.random.randint
<function RandomState.randint>
v=np.random.randint(20,300)
v
220
type(v)
int
import matplotlib.pyplot as plt
plt.hist(np.random.rand(1000),bins=100)
(array([10., 8., 10., 13., 8., 11., 9., 10., 15., 13., 12., 4., 7.,
11., 11., 12., 16., 8., 12., 6., 10., 7., 10., 12., 6., 13.,
14., 7., 8., 3., 12., 14., 13., 13., 7., 12., 8., 13., 14.,
10., 11., 7., 7., 16., 8., 15., 9., 9., 7., 10., 11., 8.,
11., 8., 12., 11., 14., 12., 9., 6., 15., 10., 3., 11., 11.,
15., 7., 8., 8., 10., 9., 17., 6., 11., 9., 4., 6., 11.,
14., 3., 9., 10., 11., 11., 8., 12., 11., 10., 11., 10., 10.,
11., 8., 9., 11., 9., 10., 10., 11., 7.]),
array([8.99344888e-05, 1.00869381e-02, 2.00839418e-02, 3.00809454e-02,
4.00779490e-02, 5.00749527e-02, 6.00719563e-02, 7.00689599e-02,
8.00659636e-02, 9.00629672e-02, 1.00059971e-01, 1.10056974e-01,
1.20053978e-01, 1.30050982e-01, 1.40047985e-01, 1.50044989e-01,
1.60041993e-01, 1.70038996e-01, 1.80036000e-01, 1.90033004e-01,
2.00030007e-01, 2.10027011e-01, 2.20024014e-01, 2.30021018e-01,
2.40018022e-01, 2.50015025e-01, 2.60012029e-01, 2.70009033e-01,
2.80006036e-01, 2.90003040e-01, 3.00000044e-01, 3.09997047e-01,
3.19994051e-01, 3.29991055e-01, 3.39988058e-01, 3.49985062e-01,
3.59982065e-01, 3.69979069e-01, 3.79976073e-01, 3.89973076e-01,
3.99970080e-01, 4.09967084e-01, 4.19964087e-01, 4.29961091e-01,
4.39958095e-01, 4.49955098e-01, 4.59952102e-01, 4.69949105e-01,
4.79946109e-01, 4.89943113e-01, 4.99940116e-01, 5.09937120e-01,
5.19934124e-01, 5.29931127e-01, 5.39928131e-01, 5.49925135e-01,
5.59922138e-01, 5.69919142e-01, 5.79916145e-01, 5.89913149e-01,
5.99910153e-01, 6.09907156e-01, 6.19904160e-01, 6.29901164e-01,
6.39898167e-01, 6.49895171e-01, 6.59892175e-01, 6.69889178e-01,
6.79886182e-01, 6.89883185e-01, 6.99880189e-01, 7.09877193e-01,
7.19874196e-01, 7.29871200e-01, 7.39868204e-01, 7.49865207e-01,
7.59862211e-01, 7.69859215e-01, 7.79856218e-01, 7.89853222e-01,
7.99850225e-01, 8.09847229e-01, 8.19844233e-01, 8.29841236e-01,
8.39838240e-01, 8.49835244e-01, 8.59832247e-01, 8.69829251e-01,
8.79826255e-01, 8.89823258e-01, 8.99820262e-01, 9.09817265e-01,
9.19814269e-01, 9.29811273e-01, 9.39808276e-01, 9.49805280e-01,
9.59802284e-01, 9.69799287e-01, 9.79796291e-01, 9.89793295e-01,
9.99790298e-01]),
<BarContainer object of 100 artists>)
B=np.random.randn(100000)
plt.hist(B,bins=200)
(array([1.000e+00, 1.000e+00, 1.000e+00, 1.000e+00, 1.000e+00, 2.000e+00,
1.000e+00, 1.000e+00, 1.000e+00, 5.000e+00, 2.000e+00, 9.000e+00,
7.000e+00, 4.000e+00, 5.000e+00, 9.000e+00, 6.000e+00, 1.100e+01,
1.200e+01, 1.100e+01, 9.000e+00, 1.600e+01, 2.400e+01, 2.300e+01,
1.800e+01, 2.100e+01, 2.800e+01, 3.600e+01, 3.400e+01, 4.900e+01,
5.100e+01, 5.800e+01, 5.100e+01, 5.800e+01, 6.000e+01, 7.300e+01,
8.000e+01, 1.080e+02, 1.120e+02, 1.150e+02, 1.110e+02, 1.250e+02,
1.440e+02, 1.860e+02, 1.910e+02, 2.080e+02, 2.170e+02, 2.370e+02,
2.600e+02, 2.760e+02, 3.250e+02, 3.660e+02, 3.750e+02, 4.140e+02,
4.090e+02, 4.630e+02, 4.800e+02, 5.540e+02, 5.840e+02, 5.300e+02,
6.150e+02, 6.460e+02, 7.090e+02, 6.990e+02, 7.930e+02, 8.090e+02,
8.130e+02, 8.710e+02, 9.180e+02, 9.780e+02, 1.034e+03, 1.100e+03,
1.148e+03, 1.169e+03, 1.203e+03, 1.229e+03, 1.289e+03, 1.307e+03,
1.402e+03, 1.397e+03, 1.412e+03, 1.482e+03, 1.492e+03, 1.478e+03,
1.566e+03, 1.622e+03, 1.550e+03, 1.565e+03, 1.592e+03, 1.680e+03,
1.629e+03, 1.636e+03, 1.690e+03, 1.659e+03, 1.634e+03, 1.546e+03,
1.670e+03, 1.654e+03, 1.648e+03, 1.623e+03, 1.588e+03, 1.590e+03,
1.546e+03, 1.542e+03, 1.527e+03, 1.469e+03, 1.501e+03, 1.489e+03,
1.377e+03, 1.374e+03, 1.339e+03, 1.341e+03, 1.293e+03, 1.205e+03,
1.149e+03, 1.173e+03, 1.063e+03, 1.060e+03, 9.790e+02, 9.710e+02,
9.380e+02, 8.720e+02, 8.110e+02, 8.380e+02, 7.030e+02, 7.320e+02,
6.840e+02, 6.540e+02, 6.210e+02, 5.450e+02, 5.320e+02, 5.230e+02,
4.440e+02, 3.930e+02, 3.930e+02, 3.340e+02, 2.990e+02, 3.120e+02,
3.050e+02, 2.730e+02, 2.370e+02, 2.370e+02, 1.970e+02, 1.760e+02,
1.850e+02, 1.720e+02, 1.430e+02, 1.430e+02, 1.340e+02, 1.330e+02,
1.040e+02, 8.700e+01, 9.500e+01, 6.100e+01, 6.100e+01, 7.200e+01,
5.400e+01, 4.800e+01, 5.700e+01, 3.300e+01, 2.900e+01, 3.100e+01,
3.100e+01, 1.900e+01, 1.800e+01, 2.100e+01, 1.800e+01, 1.800e+01,
9.000e+00, 1.200e+01, 1.200e+01, 3.000e+00, 9.000e+00, 4.000e+00,
2.000e+00, 4.000e+00, 6.000e+00, 1.000e+00, 1.000e+00, 4.000e+00,
2.000e+00, 1.000e+00, 1.000e+00, 1.000e+00, 1.000e+00, 0.000e+00,
1.000e+00, 1.000e+00, 0.000e+00, 1.000e+00, 0.000e+00, 0.000e+00,
0.000e+00, 0.000e+00, 0.000e+00, 0.000e+00, 0.000e+00, 0.000e+00,
0.000e+00, 1.000e+00]),
array([-3.96872333, -3.92661213, -3.88450092, -3.84238972, -3.80027851,
-3.75816731, -3.7160561 , -3.6739449 , -3.63183369, -3.58972249,
-3.54761129, -3.50550008, -3.46338888, -3.42127767, -3.37916647,
-3.33705526, -3.29494406, -3.25283286, -3.21072165, -3.16861045,
-3.12649924, -3.08438804, -3.04227683, -3.00016563, -2.95805442,
-2.91594322, -2.87383202, -2.83172081, -2.78960961, -2.7474984 ,
-2.7053872 , -2.66327599, -2.62116479, -2.57905359, -2.53694238,
-2.49483118, -2.45271997, -2.41060877, -2.36849756, -2.32638636,
-2.28427515, -2.24216395, -2.20005275, -2.15794154, -2.11583034,
-2.07371913, -2.03160793, -1.98949672, -1.94738552, -1.90527432,
-1.86316311, -1.82105191, -1.7789407 , -1.7368295 , -1.69471829,
-1.65260709, -1.61049588, -1.56838468, -1.52627348, -1.48416227,
-1.44205107, -1.39993986, -1.35782866, -1.31571745, -1.27360625,
-1.23149505, -1.18938384, -1.14727264, -1.10516143, -1.06305023,
-1.02093902, -0.97882782, -0.93671661, -0.89460541, -0.85249421,
-0.810383 , -0.7682718 , -0.72616059, -0.68404939, -0.64193818,
-0.59982698, -0.55771577, -0.51560457, -0.47349337, -0.43138216,
-0.38927096, -0.34715975, -0.30504855, -0.26293734, -0.22082614,
-0.17871494, -0.13660373, -0.09449253, -0.05238132, -0.01027012,
0.03184109, 0.07395229, 0.1160635 , 0.1581747 , 0.2002859 ,
0.24239711, 0.28450831, 0.32661952, 0.36873072, 0.41084193,
0.45295313, 0.49506433, 0.53717554, 0.57928674, 0.62139795,
0.66350915, 0.70562036, 0.74773156, 0.78984277, 0.83195397,
0.87406517, 0.91617638, 0.95828758, 1.00039879, 1.04250999,
1.0846212 , 1.1267324 , 1.1688436 , 1.21095481, 1.25306601,
1.29517722, 1.33728842, 1.37939963, 1.42151083, 1.46362204,
1.50573324, 1.54784444, 1.58995565, 1.63206685, 1.67417806,
1.71628926, 1.75840047, 1.80051167, 1.84262287, 1.88473408,
1.92684528, 1.96895649, 2.01106769, 2.0531789 , 2.0952901 ,
2.13740131, 2.17951251, 2.22162371, 2.26373492, 2.30584612,
2.34795733, 2.39006853, 2.43217974, 2.47429094, 2.51640215,
2.55851335, 2.60062455, 2.64273576, 2.68484696, 2.72695817,
2.76906937, 2.81118058, 2.85329178, 2.89540298, 2.93751419,
2.97962539, 3.0217366 , 3.0638478 , 3.10595901, 3.14807021,
3.19018142, 3.23229262, 3.27440382, 3.31651503, 3.35862623,
3.40073744, 3.44284864, 3.48495985, 3.52707105, 3.56918225,
3.61129346, 3.65340466, 3.69551587, 3.73762707, 3.77973828,
3.82184948, 3.86396069, 3.90607189, 3.94818309, 3.9902943 ,
4.0324055 , 4.07451671, 4.11662791, 4.15873912, 4.20085032,
4.24296152, 4.28507273, 4.32718393, 4.36929514, 4.41140634,
4.45351755]),
<BarContainer object of 200 artists>)
C=np.random.rand(2,3)
C
array([[0.25008488, 0.343122 , 0.92420939],
[0.95734876, 0.14536173, 0.5476824 ]])
C.ndim
2
D=np.arange(100).reshape(4,25)
D.shape
(4, 25)
import numpy np
File "C:\Users\sayadur\AppData\Local\Temp/ipykernel_10272/1904197115.py", line 1 import numpy np ^ SyntaxError: invalid syntax
import numpy as np
A=np.arange(100)
B=A[3:10]
print(B)
[3 4 5 6 7 8 9]
B[0]=-1200
B
array([-1200, 4, 5, 6, 7, 8, 9])
A
array([ 0, 1, 2, -1200, 4, 5, 6, 7, 8,
9, 10, 11, 12, 13, 14, 15, 16, 17,
18, 19, 20, 21, 22, 23, 24, 25, 26,
27, 28, 29, 30, 31, 32, 33, 34, 35,
36, 37, 38, 39, 40, 41, 42, 43, 44,
45, 46, 47, 48, 49, 50, 51, 52, 53,
54, 55, 56, 57, 58, 59, 60, 61, 62,
63, 64, 65, 66, 67, 68, 69, 70, 71,
72, 73, 74, 75, 76, 77, 78, 79, 80,
81, 82, 83, 84, 85, 86, 87, 88, 89,
90, 91, 92, 93, 94, 95, 96, 97, 98,
99])
B=A[3:10].copy()
B
array([-1200, 4, 5, 6, 7, 8, 9])
A
array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67,
68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99])
A[::5]
array([ 0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80,
85, 90, 95])
A[::-5]
array([99, 94, 89, 84, 79, 74, 69, 64, 59, 54, 49, 44, 39, 34, 29, 24, 19,
14, 9, 4])
B=(A==-1200)*np.arange(A.size)
B
array([0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
idx=np.argwhere(A==-1200)[0][0]
idx
3
A[idx]=3
A
array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67,
68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99])
A=np.round(10*np.random.rand(5,4))
A
array([[4., 9., 6., 4.],
[6., 6., 8., 2.],
[3., 4., 9., 5.],
[8., 6., 9., 3.],
[3., 9., 1., 6.]])
A[0:1]
array([[4., 9., 6., 4.]])
A[0,2]
6.0
A[1,:]
array([6., 6., 8., 2.])
A[0:2,1:0]
array([], shape=(2, 0), dtype=float64)
import numpy.linalg as la
la.inv(np.random.rand(3,3))
array([[ 2.60045808, 0.71864656, -2.60411358],
[-0.59663354, 1.57415212, -0.61556338],
[ 0.11676209, -1.10323528, 1.79250884]])
A.sort(axis=1)
A
array([[1., 2., 3., 4.],
[3., 3., 6., 6.],
[4., 4., 6., 8.],
[5., 6., 9., 9.],
[6., 8., 9., 9.]])
A=np.arange(100)
B=A[[3,5,6]]
B
array([3, 5, 6])
B=A[A<40]
B
array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
34, 35, 36, 37, 38, 39])
B=A[(A<40) & (A>30)]
B
array([31, 32, 33, 34, 35, 36, 37, 38, 39])
import numpy as np
A= np.round(10*np.random.rand(2,3))
A
array([[7., 1., 5.],
[1., 9., 8.]])
A+(np.arange(2).reshape(2,1))
array([[ 7., 1., 5.],
[ 2., 10., 9.]])
B=np.round(10*np.random.rand(2,2))
B
array([[ 1., 8.],
[ 0., 10.]])
C=np.hstack((A,B))
C
array([[ 7., 1., 5., 1., 8.],
[ 1., 9., 8., 0., 10.]])
A=np.random.permutation(np.arange(10))
A.sort()
A
array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
np.sort(A)
array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
A=A[::-1]
A
array([9, 8, 7, 6, 5, 4, 3, 2, 1, 0])
A=np.array(["abc","howare you",'u765','e13'])
A.sort()
A
array(['abc', 'e13', 'howare you', 'u765'], dtype='<U10')
B=np.random.rand(1000000)
%timeit sum(B)
%timeit np.sum(B)
50.8 ms ± 545 µs per loop (mean ± std. dev. of 7 runs, 10 loops each) 367 µs ± 4.88 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
def mySum(G):
s=0
for x in G:
s+=x
return s
%timeit mySum(B)
65 ms ± 1.64 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
import pandas as pd
print(pd.__version__)
1.3.4
A= pd.Series([2,3,4,5],index=['a','b','c','d'])
A.values
array([2, 3, 4, 5], dtype=int64)
type(A.values)
numpy.ndarray
type(A)
pandas.core.series.Series
A.index
Index(['a', 'b', 'c', 'd'], dtype='object')
A['a']
2
A['a':'c']
a 2 b 3 c 4 dtype: int64
grade_dict={'A':4,'A-':3.5,'B':3,'B-':2.5,'C':2}
grade=pd.Series(grade_dict)
grade.values
array([4. , 3.5, 3. , 2.5, 2. ])
marks_dict={'A':85,'A-':80,'B':75,'B-':70,'C':60}
marks=pd.Series(marks_dict)
marks.values
array([85, 80, 75, 70, 60], dtype=int64)
marks
A 85 A- 80 B 75 B- 70 C 60 dtype: int64
marks[0:2]
A 85 A- 80 dtype: int64
grade
A 4.0 A- 3.5 B 3.0 B- 2.5 C 2.0 dtype: float64
D=pd.DataFrame({'Grade':grade,'Marks':marks})
D.T
| A | A- | B | B- | C | |
|---|---|---|---|---|---|
| Grade | 4.0 | 3.5 | 3.0 | 2.5 | 2.0 |
| Marks | 85.0 | 80.0 | 75.0 | 70.0 | 60.0 |
D
| Grade | Marks | |
|---|---|---|
| A | 4.0 | 85 |
| A- | 3.5 | 80 |
| B | 3.0 | 75 |
| B- | 2.5 | 70 |
| C | 2.0 | 60 |
D.values
array([[ 4. , 85. ],
[ 3.5, 80. ],
[ 3. , 75. ],
[ 2.5, 70. ],
[ 2. , 60. ]])
D.values[2,0]
3.0
D.T
| A | A- | B | B- | C | |
|---|---|---|---|---|---|
| Grade | 4.0 | 3.5 | 3.0 | 2.5 | 2.0 |
| Marks | 85.0 | 80.0 | 75.0 | 70.0 | 60.0 |
D.values[2,0]
3.0
D['ScaledMarks']=100*(D['Marks']/90)
D
| Grade | Marks | ScaledMarks | |
|---|---|---|---|
| A | 4.0 | 85 | 94.444444 |
| A- | 3.5 | 80 | 88.888889 |
| B | 3.0 | 75 | 83.333333 |
| B- | 2.5 | 70 | 77.777778 |
| C | 2.0 | 60 | 66.666667 |
del D['ScaledMarks']
D
| Grade | Marks | |
|---|---|---|
| A | 4.0 | 85 |
| A- | 3.5 | 80 |
| B | 3.0 | 75 |
| B- | 2.5 | 70 |
| C | 2.0 | 60 |
G=D[D['Marks']>70]
G
| Grade | Marks | |
|---|---|---|
| A | 4.0 | 85 |
| A- | 3.5 | 80 |
| B | 3.0 | 75 |
A= pd.DataFrame([{'a':1,'b':4},{'a':-1,'c':-4},{'d':-5,'c':-7}])
A
| a | b | c | d | |
|---|---|---|---|---|
| 0 | 1.0 | 4.0 | NaN | NaN |
| 1 | -1.0 | NaN | -4.0 | NaN |
| 2 | NaN | NaN | -7.0 | -5.0 |
A.fillna(0)
| a | b | c | d | |
|---|---|---|---|---|
| 0 | 1.0 | 4.0 | 0.0 | 0.0 |
| 1 | -1.0 | 0.0 | -4.0 | 0.0 |
| 2 | 0.0 | 0.0 | -7.0 | -5.0 |
A.dropna?
A= pd.Series(['a','b','c','d'],index=[1,3,5,7])
A
1 a 3 b 5 c 7 d dtype: object
A[1:3]
3 b 5 c dtype: object
A.loc[1:3]
1 a 3 b dtype: object
A.iloc[1:3]
3 b 5 c dtype: object
D
| Grade | Marks | |
|---|---|---|
| A | 4.0 | 85 |
| A- | 3.5 | 80 |
| B | 3.0 | 75 |
| B- | 2.5 | 70 |
| C | 2.0 | 60 |
D.iloc[2,:]
Grade 3.0 Marks 75.0 Name: B, dtype: float64
D.iloc[::-1,:]
| Grade | Marks | |
|---|---|---|
| C | 2.0 | 60 |
| B- | 2.5 | 70 |
| B | 3.0 | 75 |
| A- | 3.5 | 80 |
| A | 4.0 | 85 |
D
| Grade | Marks | |
|---|---|---|
| A | 4.0 | 85 |
| A- | 3.5 | 80 |
| B | 3.0 | 75 |
| B- | 2.5 | 70 |
| C | 2.0 | 60 |
import pandas as pd
import numpy as np
from sklearn.impute import SimpleImputer
df =pd.read_csv('D:\sayadur\Data Science\covid_19_data\covid_19_data.csv')
df.drop(['Sno','Last Update'],axis=1,inplace=True)
--------------------------------------------------------------------------- KeyError Traceback (most recent call last) ~\AppData\Local\Temp/ipykernel_492/1737931629.py in <module> ----> 1 df.drop(['Sno','Last Update'],axis=1,inplace=True) ~\Anaconda3\lib\site-packages\pandas\util\_decorators.py in wrapper(*args, **kwargs) 309 stacklevel=stacklevel, 310 ) --> 311 return func(*args, **kwargs) 312 313 return wrapper ~\Anaconda3\lib\site-packages\pandas\core\frame.py in drop(self, labels, axis, index, columns, level, inplace, errors) 4904 weight 1.0 0.8 4905 """ -> 4906 return super().drop( 4907 labels=labels, 4908 axis=axis, ~\Anaconda3\lib\site-packages\pandas\core\generic.py in drop(self, labels, axis, index, columns, level, inplace, errors) 4148 for axis, labels in axes.items(): 4149 if labels is not None: -> 4150 obj = obj._drop_axis(labels, axis, level=level, errors=errors) 4151 4152 if inplace: ~\Anaconda3\lib\site-packages\pandas\core\generic.py in _drop_axis(self, labels, axis, level, errors) 4183 new_axis = axis.drop(labels, level=level, errors=errors) 4184 else: -> 4185 new_axis = axis.drop(labels, errors=errors) 4186 result = self.reindex(**{axis_name: new_axis}) 4187 ~\Anaconda3\lib\site-packages\pandas\core\indexes\base.py in drop(self, labels, errors) 6015 if mask.any(): 6016 if errors != "ignore": -> 6017 raise KeyError(f"{labels[mask]} not found in axis") 6018 indexer = indexer[~mask] 6019 return self.delete(indexer) KeyError: "['Sno'] not found in axis"
df
| SNo | ObservationDate | Province/State | Country/Region | Last Update | Confirmed | Deaths | Recovered | |
|---|---|---|---|---|---|---|---|---|
| 0 | 1 | 1/22/2020 | Anhui | Mainland China | 1/22/2020 17:00 | 1 | 0 | 0 |
| 1 | 2 | 1/22/2020 | Beijing | Mainland China | 1/22/2020 17:00 | 14 | 0 | 0 |
| 2 | 3 | 1/22/2020 | Chongqing | Mainland China | 1/22/2020 17:00 | 6 | 0 | 0 |
| 3 | 4 | 1/22/2020 | Fujian | Mainland China | 1/22/2020 17:00 | 1 | 0 | 0 |
| 4 | 5 | 1/22/2020 | Gansu | Mainland China | 1/22/2020 17:00 | 0 | 0 | 0 |
| ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 306424 | 306425 | 5/29/2021 | Zaporizhia Oblast | Ukraine | 5/30/2021 4:20 | 102641 | 2335 | 95289 |
| 306425 | 306426 | 5/29/2021 | Zeeland | Netherlands | 5/30/2021 4:20 | 29147 | 245 | 0 |
| 306426 | 306427 | 5/29/2021 | Zhejiang | Mainland China | 5/30/2021 4:20 | 1364 | 1 | 1324 |
| 306427 | 306428 | 5/29/2021 | Zhytomyr Oblast | Ukraine | 5/30/2021 4:20 | 87550 | 1738 | 83790 |
| 306428 | 306429 | 5/29/2021 | Zuid-Holland | Netherlands | 5/30/2021 4:20 | 391559 | 4252 | 0 |
306429 rows × 8 columns
df.drop(['SNo','Last Update'],axis=1,inplace=True)
df.head(10)
| ObservationDate | Province/State | Country/Region | Confirmed | Deaths | Recovered | |
|---|---|---|---|---|---|---|
| 0 | 1/22/2020 | Anhui | Mainland China | 1 | 0 | 0 |
| 1 | 1/22/2020 | Beijing | Mainland China | 14 | 0 | 0 |
| 2 | 1/22/2020 | Chongqing | Mainland China | 6 | 0 | 0 |
| 3 | 1/22/2020 | Fujian | Mainland China | 1 | 0 | 0 |
| 4 | 1/22/2020 | Gansu | Mainland China | 0 | 0 | 0 |
| 5 | 1/22/2020 | Guangdong | Mainland China | 26 | 0 | 0 |
| 6 | 1/22/2020 | Guangxi | Mainland China | 2 | 0 | 0 |
| 7 | 1/22/2020 | Guizhou | Mainland China | 1 | 0 | 0 |
| 8 | 1/22/2020 | Hainan | Mainland China | 4 | 0 | 0 |
| 9 | 1/22/2020 | Hebei | Mainland China | 1 | 0 | 0 |
df.rename(columns={'ObservationDate':'Date','Province/State':'Province','Country/Region':'Country'},inplace=True)
df.head(10)
| Date | Province | Country | Confirmed | Deaths | Recovered | |
|---|---|---|---|---|---|---|
| 0 | 1/22/2020 | Anhui | Mainland China | 1 | 0 | 0 |
| 1 | 1/22/2020 | Beijing | Mainland China | 14 | 0 | 0 |
| 2 | 1/22/2020 | Chongqing | Mainland China | 6 | 0 | 0 |
| 3 | 1/22/2020 | Fujian | Mainland China | 1 | 0 | 0 |
| 4 | 1/22/2020 | Gansu | Mainland China | 0 | 0 | 0 |
| 5 | 1/22/2020 | Guangdong | Mainland China | 26 | 0 | 0 |
| 6 | 1/22/2020 | Guangxi | Mainland China | 2 | 0 | 0 |
| 7 | 1/22/2020 | Guizhou | Mainland China | 1 | 0 | 0 |
| 8 | 1/22/2020 | Hainan | Mainland China | 4 | 0 | 0 |
| 9 | 1/22/2020 | Hebei | Mainland China | 1 | 0 | 0 |
df['Date']=pd.to_datetime(df['Date'])
df.head(10)
| Date | Province | Country | Confirmed | Deaths | Recovered | |
|---|---|---|---|---|---|---|
| 0 | 2020-01-22 | Anhui | Mainland China | 1 | 0 | 0 |
| 1 | 2020-01-22 | Beijing | Mainland China | 14 | 0 | 0 |
| 2 | 2020-01-22 | Chongqing | Mainland China | 6 | 0 | 0 |
| 3 | 2020-01-22 | Fujian | Mainland China | 1 | 0 | 0 |
| 4 | 2020-01-22 | Gansu | Mainland China | 0 | 0 | 0 |
| 5 | 2020-01-22 | Guangdong | Mainland China | 26 | 0 | 0 |
| 6 | 2020-01-22 | Guangxi | Mainland China | 2 | 0 | 0 |
| 7 | 2020-01-22 | Guizhou | Mainland China | 1 | 0 | 0 |
| 8 | 2020-01-22 | Hainan | Mainland China | 4 | 0 | 0 |
| 9 | 2020-01-22 | Hebei | Mainland China | 1 | 0 | 0 |
df.describe()
| Confirmed | Deaths | Recovered | |
|---|---|---|---|
| count | 3.064290e+05 | 306429.000000 | 3.064290e+05 |
| mean | 8.567091e+04 | 2036.403268 | 5.042029e+04 |
| std | 2.775516e+05 | 6410.938048 | 2.015124e+05 |
| min | -3.028440e+05 | -178.000000 | -8.544050e+05 |
| 25% | 1.042000e+03 | 13.000000 | 1.100000e+01 |
| 50% | 1.037500e+04 | 192.000000 | 1.751000e+03 |
| 75% | 5.075200e+04 | 1322.000000 | 2.027000e+04 |
| max | 5.863138e+06 | 112385.000000 | 6.399531e+06 |
df.info()
<class 'pandas.core.frame.DataFrame'> RangeIndex: 306429 entries, 0 to 306428 Data columns (total 6 columns): # Column Non-Null Count Dtype --- ------ -------------- ----- 0 Date 306429 non-null datetime64[ns] 1 Province 228329 non-null object 2 Country 306429 non-null object 3 Confirmed 306429 non-null int64 4 Deaths 306429 non-null int64 5 Recovered 306429 non-null int64 dtypes: datetime64[ns](1), int64(3), object(2) memory usage: 14.0+ MB
df=df.fillna('NA')
df.info()
<class 'pandas.core.frame.DataFrame'> RangeIndex: 306429 entries, 0 to 306428 Data columns (total 6 columns): # Column Non-Null Count Dtype --- ------ -------------- ----- 0 Date 306429 non-null object 1 Province 306429 non-null object 2 Country 306429 non-null object 3 Confirmed 306429 non-null int64 4 Deaths 306429 non-null int64 5 Recovered 306429 non-null int64 dtypes: int64(3), object(3) memory usage: 14.0+ MB
df2=df.groupby('Country')[['Country','Confirmed','Deaths','Recovered']].sum().reset_index()
df3=df2.groupby(['Country','Date'])[['Country','Date','Confirmed','Deaths','Recovered']].sum().reset_index()
--------------------------------------------------------------------------- KeyError Traceback (most recent call last) ~\AppData\Local\Temp/ipykernel_1532/1467656081.py in <module> ----> 1 df3=df2.groupby(['Country','Date'])[['Country','Date','Confirmed','Deaths','Recovered']].sum().reset_index() ~\Anaconda3\lib\site-packages\pandas\core\frame.py in groupby(self, by, axis, level, as_index, sort, group_keys, squeeze, observed, dropna) 7629 # error: Argument "squeeze" to "DataFrameGroupBy" has incompatible type 7630 # "Union[bool, NoDefault]"; expected "bool" -> 7631 return DataFrameGroupBy( 7632 obj=self, 7633 keys=by, ~\Anaconda3\lib\site-packages\pandas\core\groupby\groupby.py in __init__(self, obj, keys, axis, level, grouper, exclusions, selection, as_index, sort, group_keys, squeeze, observed, mutated, dropna) 887 from pandas.core.groupby.grouper import get_grouper 888 --> 889 grouper, exclusions, obj = get_grouper( 890 obj, 891 keys, ~\Anaconda3\lib\site-packages\pandas\core\groupby\grouper.py in get_grouper(obj, key, axis, level, sort, observed, mutated, validate, dropna) 860 in_axis, level, gpr = False, gpr, None 861 else: --> 862 raise KeyError(gpr) 863 elif isinstance(gpr, Grouper) and gpr.key is not None: 864 # Add key to exclusions KeyError: 'Date'
df2=df.groupby(['Country','Date'])[['Country','Date','Confirmed','Deaths','Recovered']].sum().reset_index()
df2
| Country | Date | Confirmed | Deaths | Recovered | |
|---|---|---|---|---|---|
| 0 | Azerbaijan | 2/28/2020 | 1 | 0 | 0 |
| 1 | ('St. Martin',) | 3/10/2020 | 2 | 0 | 0 |
| 2 | Afghanistan | 1/1/2021 | 51526 | 2191 | 41727 |
| 3 | Afghanistan | 1/10/2021 | 53489 | 2277 | 43948 |
| 4 | Afghanistan | 1/11/2021 | 53538 | 2288 | 44137 |
| ... | ... | ... | ... | ... | ... |
| 87276 | occupied Palestinian territory | 3/12/2020 | 0 | 0 | 0 |
| 87277 | occupied Palestinian territory | 3/14/2020 | 0 | 0 | 0 |
| 87278 | occupied Palestinian territory | 3/15/2020 | 0 | 0 | 0 |
| 87279 | occupied Palestinian territory | 3/16/2020 | 0 | 0 | 0 |
| 87280 | occupied Palestinian territory | 3/17/2020 | 0 | 0 | 0 |
87281 rows × 5 columns
df2=df2[df2['Confirmed']>2000000]
df2
| Country | Date | Confirmed | Deaths | Recovered | |
|---|---|---|---|---|---|
| 3047 | Argentina | 2021-02-10 | 2001034 | 49674 | 1798120 |
| 3048 | Argentina | 2021-02-11 | 2008345 | 49874 | 1806260 |
| 3049 | Argentina | 2021-02-12 | 2015496 | 50029 | 1814160 |
| 3050 | Argentina | 2021-02-13 | 2021553 | 50188 | 1820965 |
| 3051 | Argentina | 2021-02-14 | 2025798 | 50236 | 1827118 |
| ... | ... | ... | ... | ... | ... |
| 83040 | Ukraine | 2021-05-25 | 2244084 | 51682 | 2028598 |
| 83041 | Ukraine | 2021-05-26 | 2247605 | 51898 | 2043720 |
| 83042 | Ukraine | 2021-05-27 | 2251242 | 52088 | 2060753 |
| 83043 | Ukraine | 2021-05-28 | 2254674 | 52252 | 2074174 |
| 83044 | Ukraine | 2021-05-29 | 2257904 | 52414 | 2084477 |
2621 rows × 5 columns
df2=df.groupby('Country')[['Country','Confirmed','Deaths','Recovered']].mean().reset_index()
df3=df2[df2['Deaths']>10000]
df3
| Country | Confirmed | Deaths | Recovered | |
|---|---|---|---|---|
| 8 | Argentina | 1.114355e+06 | 26738.280353 | 9.685437e+05 |
| 97 | Indonesia | 5.841102e+05 | 17115.262115 | 4.987140e+05 |
| 98 | Iran | 8.603214e+05 | 33786.281116 | 7.013155e+05 |
| 164 | Poland | 8.422142e+05 | 19804.592920 | 6.854766e+05 |
| 171 | Romania | 3.770867e+05 | 10079.753813 | 3.305183e+05 |
| 191 | South Africa | 7.670511e+05 | 22727.352550 | 6.874447e+05 |
| 212 | Turkey | 1.390879e+06 | 15373.388764 | 1.267799e+06 |
df2=df.groupby(['Date'])[['Date','Deaths']].mean().reset_index()
df2
| Date | Deaths | |
|---|---|---|
| 0 | 2020-01-22 | 0.425000 |
| 1 | 2020-01-23 | 0.708333 |
| 2 | 2020-01-24 | 0.604651 |
| 3 | 2020-01-25 | 0.913043 |
| 4 | 2020-01-26 | 1.142857 |
| ... | ... | ... |
| 489 | 2021-05-25 | 4556.585621 |
| 490 | 2021-05-26 | 4573.260131 |
| 491 | 2021-05-27 | 4589.930719 |
| 492 | 2021-05-28 | 4605.381699 |
| 493 | 2021-05-29 | 4619.109804 |
494 rows × 2 columns
sorted_df = df2.sort_values(['Deaths'],ascending=False)
sorted_df
| Date | Deaths | |
|---|---|---|
| 493 | 2021-05-29 | 4619.109804 |
| 492 | 2021-05-28 | 4605.381699 |
| 491 | 2021-05-27 | 4589.930719 |
| 490 | 2021-05-26 | 4573.260131 |
| 489 | 2021-05-25 | 4556.585621 |
| ... | ... | ... |
| 4 | 2020-01-26 | 1.142857 |
| 3 | 2020-01-25 | 0.913043 |
| 1 | 2020-01-23 | 0.708333 |
| 2 | 2020-01-24 | 0.604651 |
| 0 | 2020-01-22 | 0.425000 |
494 rows × 2 columns
import numpy as np
import matplotlib.pyplot as plt
x=np.linspace(0,10,1000)
plt.plot(x,np.sin(x))
[<matplotlib.lines.Line2D at 0x26f00ca0160>]
import numpy as np
import matplotlib.pyplot as plt
x=np.linspace(0,10,1000)
y=np.sin(x)
plt.plot(x,y)
[<matplotlib.lines.Line2D at 0x26f00da9580>]
plt.scatter(x,y)
<matplotlib.collections.PathCollection at 0x26f00e066d0>
plt.scatter(x[:30],y[:30])
<matplotlib.collections.PathCollection at 0x26f7d900fd0>
plt.scatter(x[::10],y[::10],color='red')
<matplotlib.collections.PathCollection at 0x26f00f17b80>
plt.scatter?
plt.plot(x,y,color='b')
plt.plot(x,np.cos(x),color='g')
[<matplotlib.lines.Line2D at 0x26f0234e7c0>]
import pandas as pd
import numpy as np
from sklearn.impute import SimpleImputer
df =pd.read_csv('D:\sayadur\Data Science\covid_19_data\covid_19_data.csv')
df
| SNo | ObservationDate | Province/State | Country/Region | Last Update | Confirmed | Deaths | Recovered | |
|---|---|---|---|---|---|---|---|---|
| 0 | 1 | 1/22/2020 | Anhui | Mainland China | 1/22/2020 17:00 | 1 | 0 | 0 |
| 1 | 2 | 1/22/2020 | Beijing | Mainland China | 1/22/2020 17:00 | 14 | 0 | 0 |
| 2 | 3 | 1/22/2020 | Chongqing | Mainland China | 1/22/2020 17:00 | 6 | 0 | 0 |
| 3 | 4 | 1/22/2020 | Fujian | Mainland China | 1/22/2020 17:00 | 1 | 0 | 0 |
| 4 | 5 | 1/22/2020 | Gansu | Mainland China | 1/22/2020 17:00 | 0 | 0 | 0 |
| ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 306424 | 306425 | 5/29/2021 | Zaporizhia Oblast | Ukraine | 5/30/2021 4:20 | 102641 | 2335 | 95289 |
| 306425 | 306426 | 5/29/2021 | Zeeland | Netherlands | 5/30/2021 4:20 | 29147 | 245 | 0 |
| 306426 | 306427 | 5/29/2021 | Zhejiang | Mainland China | 5/30/2021 4:20 | 1364 | 1 | 1324 |
| 306427 | 306428 | 5/29/2021 | Zhytomyr Oblast | Ukraine | 5/30/2021 4:20 | 87550 | 1738 | 83790 |
| 306428 | 306429 | 5/29/2021 | Zuid-Holland | Netherlands | 5/30/2021 4:20 | 391559 | 4252 | 0 |
306429 rows × 8 columns
df(10)
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) ~\AppData\Local\Temp/ipykernel_1532/801129012.py in <module> ----> 1 df(10) TypeError: 'DataFrame' object is not callable
df.head(10)
| Date | Province | Country | Confirmed | Deaths | Recovered | |
|---|---|---|---|---|---|---|
| 0 | 1/22/2020 | Anhui | Mainland China | 1 | 0 | 0 |
| 1 | 1/22/2020 | Beijing | Mainland China | 14 | 0 | 0 |
| 2 | 1/22/2020 | Chongqing | Mainland China | 6 | 0 | 0 |
| 3 | 1/22/2020 | Fujian | Mainland China | 1 | 0 | 0 |
| 4 | 1/22/2020 | Gansu | Mainland China | 0 | 0 | 0 |
| 5 | 1/22/2020 | Guangdong | Mainland China | 26 | 0 | 0 |
| 6 | 1/22/2020 | Guangxi | Mainland China | 2 | 0 | 0 |
| 7 | 1/22/2020 | Guizhou | Mainland China | 1 | 0 | 0 |
| 8 | 1/22/2020 | Hainan | Mainland China | 4 | 0 | 0 |
| 9 | 1/22/2020 | Hebei | Mainland China | 1 | 0 | 0 |
df.rename(columns={'ObservationDate':'Date','Province/State':'Province','Country/Region':'Country'},inplace=True)
df.drop(['SNo','Last Update'],axis=1,inplace=True)
countries=df2['country'].unique()
len(countries)
--------------------------------------------------------------------------- KeyError Traceback (most recent call last) ~\Anaconda3\lib\site-packages\pandas\core\indexes\base.py in get_loc(self, key, method, tolerance) 3360 try: -> 3361 return self._engine.get_loc(casted_key) 3362 except KeyError as err: ~\Anaconda3\lib\site-packages\pandas\_libs\index.pyx in pandas._libs.index.IndexEngine.get_loc() ~\Anaconda3\lib\site-packages\pandas\_libs\index.pyx in pandas._libs.index.IndexEngine.get_loc() pandas\_libs\hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item() pandas\_libs\hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item() KeyError: 'country' The above exception was the direct cause of the following exception: KeyError Traceback (most recent call last) ~\AppData\Local\Temp/ipykernel_1532/378304976.py in <module> ----> 1 countries=df2['country'].unique() 2 len(countries) ~\Anaconda3\lib\site-packages\pandas\core\frame.py in __getitem__(self, key) 3456 if self.columns.nlevels > 1: 3457 return self._getitem_multilevel(key) -> 3458 indexer = self.columns.get_loc(key) 3459 if is_integer(indexer): 3460 indexer = [indexer] ~\Anaconda3\lib\site-packages\pandas\core\indexes\base.py in get_loc(self, key, method, tolerance) 3361 return self._engine.get_loc(casted_key) 3362 except KeyError as err: -> 3363 raise KeyError(key) from err 3364 3365 if is_scalar(key) and isna(key) and not self.hasnans: KeyError: 'country'
df2=df.groupby(['Country','Date'])[['Country','Date','Confirmed','Deaths','Rec
File "C:\Users\sayadur\AppData\Local\Temp/ipykernel_1532/4197644617.py", line 1 df2=df.groupby(['Country','Date'])[['Country','Date','Confirmed','Deaths','Rec ^ SyntaxError: EOL while scanning string literal
df2=df.groupby('Country')[['Country','Confirmed','Deaths','Recovered']].sum().reset_index()
df2.head(10)
| Country | Confirmed | Deaths | Recovered | |
|---|---|---|---|---|
| 0 | Azerbaijan | 1 | 0 | 0 |
| 1 | ('St. Martin',) | 2 | 0 | 0 |
| 2 | Afghanistan | 17026442 | 669075 | 13464399 |
| 3 | Albania | 19768869 | 375955 | 13945256 |
| 4 | Algeria | 27684358 | 834464 | 18959299 |
| 5 | Andorra | 2379802 | 32100 | 2162473 |
| 6 | Angola | 4764863 | 116489 | 3683041 |
| 7 | Antigua and Barbuda | 143868 | 4059 | 109958 |
| 8 | Argentina | 504802880 | 12112441 | 438750295 |
| 9 | Armenia | 42536277 | 770759 | 37101575 |
df3=df.groupby(['Country','Date'])[['Country','Date','Confirmed','Deaths','Recovered']].sum().reset_index()
df3.head(10)
| Country | Date | Confirmed | Deaths | Recovered | |
|---|---|---|---|---|---|
| 0 | Azerbaijan | 2/28/2020 | 1 | 0 | 0 |
| 1 | ('St. Martin',) | 3/10/2020 | 2 | 0 | 0 |
| 2 | Afghanistan | 1/1/2021 | 51526 | 2191 | 41727 |
| 3 | Afghanistan | 1/10/2021 | 53489 | 2277 | 43948 |
| 4 | Afghanistan | 1/11/2021 | 53538 | 2288 | 44137 |
| 5 | Afghanistan | 1/12/2021 | 53584 | 2301 | 44608 |
| 6 | Afghanistan | 1/13/2021 | 53584 | 2301 | 44850 |
| 7 | Afghanistan | 1/14/2021 | 53775 | 2314 | 45298 |
| 8 | Afghanistan | 1/15/2021 | 53831 | 2324 | 45434 |
| 9 | Afghanistan | 1/16/2021 | 53938 | 2336 | 45465 |
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from sklearn.impute import SimpleImputer
df =pd.read_csv('D:\sayadur\Data Science\covid_19_data\covid_19_data.csv')
df.rename(columns={'ObservationDate':'Date','Province/State':'Province','Country/Region':'Country'},inplace=True)
df['Date']=pd.to_datetime(df['Date'])
df.drop(['SNo','Last Update'],axis=1,inplace=True)
df3=df.groupby(['Country','Date'])[['Country','Date','Confirmed','Deaths','Recovered']].sum().reset_index()
df4=df.groupby(['Date'])[['Date','Confirmed','Deaths','Recovered']].sum().reset_index()
countries=df3['Country'].unique()
for idx in range(0,len(countries)):
C=df3[df3['Country']==countries[idx]].reset_index()
plt.scatter(np.arange(0,len(C)),C['Confirmed'],color='blue',label='Confirmed')
plt.scatter(np.arange(0,len(C)),C['Recovered'],color='green',label='Recovered')
plt.scatter(np.arange(0,len(C)),C['Deaths'],color='red',label='Deaths')
plt.title(countries[idx])
plt.xlabel('Days since the first suspect')
plt.ylabel('Number of case')
plt.legend()
plt.show()
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from sklearn.impute import SimpleImputer
df =pd.read_csv('D:\sayadur\Data Science\covid_19_data\covid_19_data.csv')
df.rename(columns={'ObservationDate':'Date','Province/State':'Province','Country/Region':'Country'},inplace=True)
df['Date']=pd.to_datetime(df['Date'])
df.drop(['SNo','Last Update'],axis=1,inplace=True)
df4=df.groupby(['Date'])[['Date','Confirmed','Deaths','Recovered']].sum().reset_index()
C=df4
plt.scatter(np.arange(0,len(C)),C['Confirmed'],color='blue',label='Confirmed')
plt.scatter(np.arange(0,len(C)),C['Recovered'],color='green',label='Recovered')
plt.scatter(np.arange(0,len(C)),C['Deaths'],color='red',label='Deaths')
plt.title('World')
plt.xlabel('Days since the first suspect')
plt.ylabel('Number of case')
plt.legend()
plt.show()
def countryCovidGraph():
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from sklearn.impute import SimpleImputer
df =pd.read_csv('D:\sayadur\Data Science\covid_19_data\covid_19_data.csv')
df.rename(columns={'ObservationDate':'Date','Province/State':'Province','Country/Region':'Country'},inplace=True)
df['Date']=pd.to_datetime(df['Date'])
df.drop(['SNo','Last Update'],axis=1,inplace=True)
df3=df.groupby(['Country','Date'])[['Country','Date','Confirmed','Deaths','Recovered']].sum().reset_index()
df4=df.groupby(['Date'])[['Date','Confirmed','Deaths','Recovered']].sum().reset_index()
countries=df3['Country'].unique()
for idx in range(0,len(countries)):
C=df3[df3['Country']==countries[idx]].reset_index()
plt.scatter(np.arange(0,len(C)),C['Confirmed'],color='blue',label='Confirmed')
plt.scatter(np.arange(0,len(C)),C['Recovered'],color='green',label='Recovered')
plt.scatter(np.arange(0,len(C)),C['Deaths'],color='red',label='Deaths')
plt.title(countries[idx])
plt.xlabel('Days since the first suspect')
plt.ylabel('Number of case')
plt.legend()
plt.show()
return True
countryCovidGraph()
True
pip install nbconvert[webpdf]
Requirement already satisfied: nbconvert[webpdf] in c:\users\sayadur\anaconda3\lib\site-packages (6.1.0) Requirement already satisfied: entrypoints>=0.2.2 in c:\users\sayadur\anaconda3\lib\site-packages (from nbconvert[webpdf]) (0.3) Requirement already satisfied: pygments>=2.4.1 in c:\users\sayadur\anaconda3\lib\site-packages (from nbconvert[webpdf]) (2.10.0) Requirement already satisfied: mistune<2,>=0.8.1 in c:\users\sayadur\anaconda3\lib\site-packages (from nbconvert[webpdf]) (0.8.4) Requirement already satisfied: traitlets>=5.0 in c:\users\sayadur\anaconda3\lib\site-packages (from nbconvert[webpdf]) (5.1.0) Requirement already satisfied: nbformat>=4.4 in c:\users\sayadur\anaconda3\lib\site-packages (from nbconvert[webpdf]) (5.1.3) Requirement already satisfied: bleach in c:\users\sayadur\anaconda3\lib\site-packages (from nbconvert[webpdf]) (4.0.0) Requirement already satisfied: testpath in c:\users\sayadur\anaconda3\lib\site-packages (from nbconvert[webpdf]) (0.5.0) Requirement already satisfied: defusedxml in c:\users\sayadur\anaconda3\lib\site-packages (from nbconvert[webpdf]) (0.7.1) Requirement already satisfied: jupyter-core in c:\users\sayadur\anaconda3\lib\site-packages (from nbconvert[webpdf]) (4.8.1) Requirement already satisfied: jinja2>=2.4 in c:\users\sayadur\anaconda3\lib\site-packages (from nbconvert[webpdf]) (2.11.3) Requirement already satisfied: pandocfilters>=1.4.1 in c:\users\sayadur\anaconda3\lib\site-packages (from nbconvert[webpdf]) (1.4.3) Requirement already satisfied: jupyterlab-pygments in c:\users\sayadur\anaconda3\lib\site-packages (from nbconvert[webpdf]) (0.1.2) Requirement already satisfied: nbclient<0.6.0,>=0.5.0 in c:\users\sayadur\anaconda3\lib\site-packages (from nbconvert[webpdf]) (0.5.3) Collecting pyppeteer==0.2.2 Downloading pyppeteer-0.2.2-py3-none-any.whl (145 kB) Collecting pyee<8.0.0,>=7.0.1 Downloading pyee-7.0.4-py2.py3-none-any.whl (12 kB) Requirement already satisfied: appdirs<2.0.0,>=1.4.3 in c:\users\sayadur\anaconda3\lib\site-packages (from pyppeteer==0.2.2->nbconvert[webpdf]) (1.4.4) Requirement already satisfied: urllib3<2.0.0,>=1.25.8 in c:\users\sayadur\anaconda3\lib\site-packages (from pyppeteer==0.2.2->nbconvert[webpdf]) (1.26.7) Collecting websockets<9.0,>=8.1 Downloading websockets-8.1.tar.gz (58 kB) Requirement already satisfied: tqdm<5.0.0,>=4.42.1 in c:\users\sayadur\anaconda3\lib\site-packages (from pyppeteer==0.2.2->nbconvert[webpdf]) (4.62.3) Requirement already satisfied: MarkupSafe>=0.23 in c:\users\sayadur\anaconda3\lib\site-packages (from jinja2>=2.4->nbconvert[webpdf]) (1.1.1) Requirement already satisfied: jupyter-client>=6.1.5 in c:\users\sayadur\anaconda3\lib\site-packages (from nbclient<0.6.0,>=0.5.0->nbconvert[webpdf]) (6.1.12) Requirement already satisfied: async-generator in c:\users\sayadur\anaconda3\lib\site-packages (from nbclient<0.6.0,>=0.5.0->nbconvert[webpdf]) (1.10) Requirement already satisfied: nest-asyncio in c:\users\sayadur\anaconda3\lib\site-packages (from nbclient<0.6.0,>=0.5.0->nbconvert[webpdf]) (1.5.1) Requirement already satisfied: python-dateutil>=2.1 in c:\users\sayadur\anaconda3\lib\site-packages (from jupyter-client>=6.1.5->nbclient<0.6.0,>=0.5.0->nbconvert[webpdf]) (2.8.2) Requirement already satisfied: tornado>=4.1 in c:\users\sayadur\anaconda3\lib\site-packages (from jupyter-client>=6.1.5->nbclient<0.6.0,>=0.5.0->nbconvert[webpdf]) (6.1) Requirement already satisfied: pyzmq>=13 in c:\users\sayadur\anaconda3\lib\site-packages (from jupyter-client>=6.1.5->nbclient<0.6.0,>=0.5.0->nbconvert[webpdf]) (22.2.1) Requirement already satisfied: pywin32>=1.0 in c:\users\sayadur\anaconda3\lib\site-packages (from jupyter-core->nbconvert[webpdf]) (228) Requirement already satisfied: ipython-genutils in c:\users\sayadur\anaconda3\lib\site-packages (from nbformat>=4.4->nbconvert[webpdf]) (0.2.0) Requirement already satisfied: jsonschema!=2.5.0,>=2.4 in c:\users\sayadur\anaconda3\lib\site-packages (from nbformat>=4.4->nbconvert[webpdf]) (3.2.0) Requirement already satisfied: pyrsistent>=0.14.0 in c:\users\sayadur\anaconda3\lib\site-packages (from jsonschema!=2.5.0,>=2.4->nbformat>=4.4->nbconvert[webpdf]) (0.18.0) Requirement already satisfied: attrs>=17.4.0 in c:\users\sayadur\anaconda3\lib\site-packages (from jsonschema!=2.5.0,>=2.4->nbformat>=4.4->nbconvert[webpdf]) (21.2.0) Requirement already satisfied: setuptools in c:\users\sayadur\anaconda3\lib\site-packages (from jsonschema!=2.5.0,>=2.4->nbformat>=4.4->nbconvert[webpdf]) (58.0.4) Requirement already satisfied: six>=1.11.0 in c:\users\sayadur\anaconda3\lib\site-packages (from jsonschema!=2.5.0,>=2.4->nbformat>=4.4->nbconvert[webpdf]) (1.16.0) Requirement already satisfied: colorama in c:\users\sayadur\anaconda3\lib\site-packages (from tqdm<5.0.0,>=4.42.1->pyppeteer==0.2.2->nbconvert[webpdf]) (0.4.4) Requirement already satisfied: webencodings in c:\users\sayadur\anaconda3\lib\site-packages (from bleach->nbconvert[webpdf]) (0.5.1) Requirement already satisfied: packaging in c:\users\sayadur\anaconda3\lib\site-packages (from bleach->nbconvert[webpdf]) (21.0) Requirement already satisfied: pyparsing>=2.0.2 in c:\users\sayadur\anaconda3\lib\site-packages (from packaging->bleach->nbconvert[webpdf]) (3.0.4) Building wheels for collected packages: websockets Building wheel for websockets (setup.py): started Building wheel for websockets (setup.py): finished with status 'done' Created wheel for websockets: filename=websockets-8.1-cp39-cp39-win_amd64.whl size=62758 sha256=020721ed39ecb589deec8a5cdfb2cef5ce9da54e530ba15376b3cd017eb58625 Stored in directory: c:\users\sayadur\appdata\local\pip\cache\wheels\d8\b9\a0\b97b211aeda2ebd6ac2e43fc300d308dbf1f9df520ed390cae Successfully built websockets Installing collected packages: websockets, pyee, pyppeteer Successfully installed pyee-7.0.4 pyppeteer-0.2.2 websockets-8.1 Note: you may need to restart the kernel to use updated packages.